﻿<%@ WebHandler Language="C#" Class="ServiceChargeAnys" %>

using System;
using System.Web;

public class ServiceChargeAnys : AjaxHandlerBase {

    public override void RequestProcess(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";

        string strRet = "";
        try
        {
            string strOp = context.Request["op"];
            switch (strOp.ToLower())
            {
                case "search":
                    strRet = Search(context);
                    break;
                case "exportall":
                    ExportAll(context);
                    break;
                default:
                    break;
            }

            context.Response.Write(strRet);
        }
        catch (Exception ex)
        {
            strRet = retExecResult(Chenxin.Lib.Utility.Constants.ExecResult.Error, ex.Message, "");
            context.Response.Write(strRet);
        }
    }

    private string Search(HttpContext context)
    {
        string strParam = string.Empty;
        System.Collections.Generic.Dictionary<string, string> dicParams = new System.Collections.Generic.Dictionary<string, string>();

        strParam = context.Request.Params["pagesize"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("PageSize", strParam);
        }
        strParam = context.Request.Params["pageindex"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("PageIndex", strParam);
        }
        strParam = context.Request.Params["sort"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("Sort", strParam);
        }
        strParam = context.Request.Params["StartTime"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("StartTime", strParam);
        }
        strParam = context.Request.Params["EndTime"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("EndTime", strParam);
        }
        strParam = context.Request.Params["Keyword"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("Keyword", strParam);
        }
        strParam = context.Request.Params["BalanceStatus"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("BalanceStatus", strParam);
        }
        strParam = context.Request.Params["DateType"];
        if (!string.IsNullOrEmpty(strParam))
        {
            dicParams.Add("DateType", strParam);
        }

        if (!string.IsNullOrEmpty(context.Request.Params["departid"]))
        {
            dicParams.Add("DepartId", context.Request.Params["departid"]);
        }
        else if (!string.IsNullOrEmpty(context.Request.Params["areaid"]))
        {
            dicParams.Add("AreaId", context.Request.Params["areaid"]);
        }
        else if (!string.IsNullOrEmpty(context.Request.Params["companyid"]))
        {
            dicParams.Add("CompanyId", context.Request.Params["companyid"]);
        }
        if (!string.IsNullOrEmpty(context.Request.Params["cityid"]))
        {
            dicParams.Add("CityId", context.Request.Params["cityid"]);
        }
        else
        {
            dicParams.Add("CompanyId", CurrentUserInfo.CompanyId.ToString());
        }

        
        return "";
    }

    private void ExportAll(HttpContext context)
    {
    }
}